﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ValidationFramework.Reflection
{
	public interface ITypeCache
	{
		// --- Methods

		/// <summary>
		/// Clear all <see cref="TypeDescriptor"/>s from <see cref="TypeCache"/>.
		/// </summary>
		void Clear();

		/// <summary>
		/// Get, and adds to the cache, a <see cref="TypeDescriptor"/> for a <see cref="Type"/>. 
		/// </summary>
		/// <typeparam name="T">The <see cref="Type"/> for which to get the <see cref="TypeDescriptor"/>.</typeparam>
		/// <returns>A <see cref="TypeDescriptor"/> corresponding  to <typeparamref name="T"/>.</returns>
		TypeDescriptor GetType<T>() where T : class;

		/// <summary>
		/// Get, and adds to the cache, a <see cref="TypeDescriptor"/> for a <see cref="RuntimeTypeHandle"/>. 
		/// </summary>
		/// <param name="runtimeTypeHandle">The <see cref="RuntimeTypeHandle"/> for which to get the <see cref="TypeDescriptor"/>.</param>
		/// <returns>A <see cref="TypeDescriptor"/> corresponding  to <paramref name="runtimeTypeHandle"/>.</returns>
		/// <exception cref="ArgumentException"><paramref name="runtimeTypeHandle"/> represents an interface.</exception>
		TypeDescriptor GetType(RuntimeTypeHandle runtimeTypeHandle);

		/// <summary>
		/// Removes <see cref="TypeDescriptor"/> for <see cref="Type"/> from cache. 
		/// </summary>
		/// <typeparam name="T">The <see cref="Type"/> for which to get the <see cref="TypeDescriptor"/>.</typeparam>
		void RemoveType<T>() where T : class;

		/// <summary>
		/// Removes <see cref="TypeDescriptor"/> for <see cref="Type"/> from cache. 
		/// </summary>
		/// <param name="runtimeTypeHandle">The <see cref="RuntimeTypeHandle"/> for which to get the <see cref="TypeDescriptor"/>.</param>
		/// <exception cref="ArgumentException"><paramref name="runtimeTypeHandle"/> represents an interface.</exception>
		void RemoveType(RuntimeTypeHandle runtimeTypeHandle);
	}
}
